<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登录</title>
</head>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
      $(document).ready(function(){
  
      })
</script>
<body>
	<h1>
		<shiro:hasRole name="admin">欢迎管理员</shiro:hasRole>
		<shiro:hasRole name="customer">欢迎用户</shiro:hasRole>${user.username }光临!请选择你的操作:</h1>
	<br>

	<!-- shiro标签实现资源权限控制，只有获得权限才能显示相关资源 -->
	<ul>
		<shiro:hasPermission name="add">
			<li>增加</li>
		</shiro:hasPermission>
		<shiro:hasPermission name="delete">
			<li>删除</li>
		</shiro:hasPermission>
		<shiro:hasPermission name="update">
			<li>修改</li>
		</shiro:hasPermission>
		<shiro:hasPermission name="query">
			<li>查询</li>
		</shiro:hasPermission>
	</ul>
	<a href="${pageContext.request.contextPath }/logOut">点我注销</a>
	<shiro:hasRole name="admin">
		<div>
			<table title="用户权限管理">
				<thead>
					<tr>
						<td>用户名</td>
						<td>用户角色</td>
					</tr>
				</thead>
				<c:forEach items="${users }" var="user">
					<tr>
						<td>${user.username}</td>
						<td>
						    <select>
                               <c:forEach items="${user.roles} " var="role">
                                   <option>${role}</option>                            
                               </c:forEach> 
						    </select>
						</td>
					</tr>
				</c:forEach>
			</table>
		</div>
	</shiro:hasRole>
</body>
</html>